package com.huahua.api.entity.developTool.github.vo;

import com.huahua.api.enums.GithubAddressTypeEnum;
import lombok.Data;

import java.util.List;

/**
 * @author LoveHuaHua
 * @date 2025年03月01日 12:47
 * @description believe in yourself
 */
@Data
public class GithubObtainInfoVo {

    /**
     * URL
     */
    private String address;


    /**
     * 作者
     */
    private String author;
    /**
     * 仓库名称
     */
    private String repositoryName;
    /**
     * 分支名称
     */
    private String branchName;

    /**
     * github地址类型 enum
     */
    private String githubAddressType;


    public static GithubObtainInfoVo error(String address) {
        GithubObtainInfoVo githubObtainInfoVo = new GithubObtainInfoVo();
        githubObtainInfoVo.address = address;
        githubObtainInfoVo.githubAddressType = GithubAddressTypeEnum.ERROR.getType();
        return githubObtainInfoVo;
    }

    public static GithubObtainInfoVo success(String address, String author, String repositoryName,GithubAddressTypeEnum githubAddressTypeEnum,String branchName) {
        GithubObtainInfoVo githubObtainInfoVo = new GithubObtainInfoVo();
        githubObtainInfoVo.address = address;
        githubObtainInfoVo.author = author;
        githubObtainInfoVo.repositoryName = repositoryName;
        githubObtainInfoVo.branchName = branchName;
        githubObtainInfoVo.githubAddressType = githubAddressTypeEnum.getType();
        return githubObtainInfoVo;
    }

    public static GithubObtainInfoVo success(String address, String author, String repositoryName,GithubAddressTypeEnum githubAddressTypeEnum) {
        return success(address,author,repositoryName,githubAddressTypeEnum,null);
    }

    public GithubAddressTypeEnum toTypeEnum(){
        return GithubAddressTypeEnum.toEnum(this.githubAddressType);
    }
}
